package com.tuo51.observation.repositories;

import com.tuo51.observation.domain.ObservateRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;


@Repository
public interface ObservateRecordRepository extends JpaRepository<ObservateRecord, String>, JpaSpecificationExecutor<ObservateRecord> {

    @Query(value = "select * from ob_record r where r.created > curdate() and r.childrenId = :childrenId order by r.created desc limit 1", nativeQuery = true)
    ObservateRecord findTop1ByCurdate(@Param("childrenId") String childrenId);

}
